home *** CD-ROM | disk | FTP | other *** search
/ FishMarket 1.0 / FishMarket v1.0.iso / fishies / 426-450 / disk_441 / dme / src / rexx / storage.h < prev    next >
C/C++ Source or Header  |  1992-05-06  |  11KB  |  231 lines

  1. /* === rexx/storage.h ==================================================
  2.  *
  3.  * Copyright (c) 1986, 1987 by William S. Hawes (All Rights Reserved)
  4.  *
  5.  * =====================================================================
  6.  * Header file to define ARexx data structures.
  7.  */
  8.  
  9. #ifndef REXX_STORAGE_H
  10. #define REXX_STORAGE_H
  11.  
  12. #ifndef EXEC_TYPES_H
  13. #include "exec/types.h"
  14. #endif
  15.  
  16. #ifndef EXEC_NODES_H
  17. #include "exec/nodes.h"
  18. #endif
  19.  
  20. #ifndef EXEC_LISTS_H
  21. #include "exec/lists.h"
  22. #endif
  23.  
  24. #ifndef EXEC_PORTS_H
  25. #include "exec/ports.h"
  26. #endif
  27.  
  28. #ifndef EXEC_LIBRARIES_H
  29. #include "exec/libraries.h"
  30. #endif
  31.  
  32. /* The RexxStr structure is used to maintain the internal strings in REXX.
  33.  * It includes the buffer area for the string and associated attributes.
  34.  * This is actually a variable-length structure; it is allocated for a
  35.  * specific length string, and the length is never modified thereafter
  36.  * (since it's used for recycling).
  37.  */
  38.  
  39. struct NexxStr {
  40.    LONG     ns_Ivalue;                 /* integer value                 */
  41.    UWORD    ns_Length;                 /* length in bytes (excl null)   */
  42.    UBYTE    ns_Flags;                  /* attribute flags               */
  43.    UBYTE    ns_Hash;                   /* hash code                     */
  44.    BYTE     ns_Buff[8];                /* buffer area for strings       */
  45.    };                                  /* size: 16 bytes (minimum)      */
  46.  
  47. #define NXADDLEN 9                     /* offset plus null byte         */
  48. #define IVALUE(nsPtr) (nsPtr->ns_Ivalue)
  49.  
  50. /* String attribute flag bit definitions                                */
  51. #define NSB_KEEP     0                 /* permanent string?             */
  52. #define NSB_STRING   1                 /* string form valid?            */
  53. #define NSB_NOTNUM   2                 /* non-numeric?                  */
  54. #define NSB_NUMBER   3                 /* a valid number?               */
  55. #define NSB_BINARY   4                 /* integer value saved?          */
  56. #define NSB_FLOAT    5                 /* floating point format?        */
  57. #define NSB_EXT      6                 /* an external string?           */
  58. #define NSB_SOURCE   7                 /* part of the program source?   */
  59.  
  60. /* The flag form of the string attributes                               */
  61. #define NSF_KEEP     (1 << NSB_KEEP  )
  62. #define NSF_STRING   (1 << NSB_STRING)
  63. #define NSF_NOTNUM   (1 << NSB_NOTNUM)
  64. #define NSF_NUMBER   (1 << NSB_NUMBER)
  65. #define NSF_BINARY   (1 << NSB_BINARY)
  66. #define NSF_FLOAT    (1 << NSB_FLOAT )
  67. #define NSF_EXT      (1 << NSB_EXT   )
  68. #define NSF_SOURCE   (1 << NSB_SOURCE)
  69.  
  70. /* Combinations of flags                                                */
  71. #define NSF_INTNUM   (NSF_NUMBER | NSF_BINARY | NSF_STRING)
  72. #define NSF_DPNUM    (NSF_NUMBER | NSF_FLOAT)
  73. #define NSF_ALPHA    (NSF_NOTNUM | NSF_STRING)
  74. #define NSF_OWNED    (NSF_SOURCE | NSF_EXT | NSF_KEEP)
  75. #define KEEPSTR      (NSF_STRING | NSF_SOURCE | NSF_NOTNUM)
  76. #define KEEPNUM      (NSF_STRING | NSF_SOURCE | NSF_NUMBER | NSF_BINARY)
  77.  
  78. /* The RexxArg structure is identical to the NexxStr structure, but
  79.  * is allocated from system memory rather than from internal storage.
  80.  * This structure is used for passing arguments to external programs.
  81.  * It is usually passed as an "argstring", a pointer to the string buffer.
  82.  */
  83. struct RexxArg {
  84.    LONG     ra_Size;                   /* total allocated length        */
  85.    UWORD    ra_Length;                 /* length of string              */
  86.    UBYTE    ra_Flags;                  /* attribute flags               */
  87.    UBYTE    ra_Hash;                   /* hash code                     */
  88.    BYTE     ra_Buff[8];                /* buffer area                   */
  89.    };                                  /* size: 16 bytes (minimum)      */
  90.  
  91. /* The RexxMsg structure is used for all communications with Rexx programs.
  92.  * It is an EXEC message with a parameter block appended.
  93.  */
  94.  
  95. struct RexxMsg {
  96.    struct Message rm_Node;             /* EXEC message structure        */
  97.    APTR     rm_TaskBlock;              /* pointer to global structure   */
  98.    APTR     rm_LibBase;                /* library base                  */
  99.    LONG     rm_Action;                 /* command (action) code         */
  100.    LONG     rm_Result1;                /* primary result (return code)  */
  101.    LONG     rm_Result2;                /* secondary result              */
  102.    STRPTR   rm_Args[16];               /* argument block (ARG0-ARG15)   */
  103.  
  104.    struct MsgPort *rm_PassPort;        /* forwarding port               */
  105.    STRPTR   rm_CommAddr;               /* host address (port name)      */
  106.    STRPTR   rm_FileExt;                /* file extension                */
  107.    LONG     rm_Stdin;                  /* input stream (filehandle)     */
  108.    LONG     rm_Stdout;                 /* output stream (filehandle)    */
  109.    LONG     rm_avail;                  /* future expansion              */
  110.    };                                  /* size: 128 bytes               */
  111.  
  112.  
  113. /* Field definitions                                                    */
  114. #define ARG0(rmp) (rmp->rm_Args[0])    /* start of argblock             */
  115. #define ARG1(rmp) (rmp->rm_Args[1])    /* first argument                */
  116. #define ARG2(rmp) (rmp->rm_Args[2])    /* second argument               */
  117.  
  118. #define MAXRMARG  15                   /* maximum arguments             */
  119.  
  120. /* Command (action) codes for message packets                           */
  121. #define RXCOMM    0x01000000           /* a command-level invocation    */
  122. #define RXFUNC    0x02000000           /* a function call               */
  123. #define RXCLOSE   0x03000000           /* close the port                */
  124. #define RXQUERY   0x04000000           /* query for information         */
  125. #define RXADDFH   0x07000000           /* add a function host           */
  126. #define RXADDLIB  0x08000000           /* add a function library        */
  127. #define RXREMLIB  0x09000000           /* remove a function library     */
  128. #define RXADDCON  0x0A000000           /* add/update a ClipList string  */
  129. #define RXREMCON  0x0B000000           /* remove a ClipList string      */
  130. #define RXTCOPN   0x0C000000           /* open the trace console        */
  131. #define RXTCCLS   0x0D000000           /* close the trace console       */
  132.  
  133. /* Command modifier flag bits                                           */
  134. #define RXFB_NOIO    16                /* suppress I/O inheritance?     */
  135. #define RXFB_RESULT  17                /* result string expected?       */
  136. #define RXFB_STRING  18                /* program is a "string file"?   */
  137. #define RXFB_TOKEN   19                /* tokenize the command line?    */
  138. #define RXFB_NONRET  20                /* a "no-return" message?        */
  139.  
  140. /* Modifier flags                                                       */
  141. #define RXFF_RESULT  (1 << RXFB_RESULT)
  142. #define RXFF_STRING  (1 << RXFB_STRING)
  143. #define RXFF_TOKEN   (1 << RXFB_TOKEN )
  144. #define RXFF_NONRET  (1 << RXFB_NONRET)
  145.  
  146. #define RXCODEMASK   0xFF000000
  147. #define RXARGMASK    0x0000000F
  148.  
  149. /* The RexxRsrc structure is used to manage global resources.
  150.  * The name string for each node is created as a RexxArg structure,
  151.  * and the total size of the node is saved in the "rr_Size" field.
  152.  * Functions are provided to allocate and release resource nodes.
  153.  * If special deletion operations are required, an offset and base can
  154.  * be provided in "rr_Func" and "rr_Base", respectively.  This function
  155.  * will be called with the base in register A6 and the node in A0.
  156.  */
  157.  
  158. struct RexxRsrc {
  159.    struct Node rr_Node;
  160.    WORD     rr_Func;                   /* "auto-delete" offset          */
  161.    APTR     rr_Base;                   /* "auto-delete" base            */
  162.    LONG     rr_Size;                   /* total size of node            */
  163.    LONG     rr_Arg1;                   /* available ...                 */
  164.    LONG     rr_Arg2;                   /* available ...                 */
  165.    };                                  /* size: 32 bytes                */
  166.  
  167. /* Resource node types                                                  */
  168. #define RRT_ANY      0                 /* any node type ...             */
  169. #define RRT_LIB      1                 /* a function library            */
  170. #define RRT_PORT     2                 /* a public port                 */
  171. #define RRT_FILE     3                 /* a file IoBuff                 */
  172. #define RRT_HOST     4                 /* a function host               */
  173. #define RRT_CLIP     5                 /* a Clip List node              */
  174.  
  175. /* The RexxTask structure holds the fields used by REXX to communicate with
  176.  * external processes, including the client task.  It includes the global
  177.  * data structure (and the base environment).  The structure is passed to
  178.  * the newly-created task in its "wake-up" message.
  179.  */
  180.  
  181. #define GLOBALSZ  200                  /* total size of GlobalData      */
  182.  
  183. struct RexxTask {
  184.    BYTE     rt_Global[GLOBALSZ];       /* global data structure         */
  185.    struct MsgPort rt_MsgPort;          /* global message port           */
  186.    UBYTE    rt_Flags;                  /* task flag bits                */
  187.    BYTE     rt_SigBit;                 /* signal bit                    */
  188.  
  189.    APTR     rt_ClientID;               /* the client's task ID
  190.    APTR     rt_MsgPkt;                 /* the packet being processed
  191.    APTR     rt_TaskID;                 /* our task ID
  192.    APTR     rt_RexxPort;               /* the REXX public port
  193.  
  194.    APTR     rt_ErrTrap;                /* Error trap address
  195.    APTR     rt_StackPtr;               /* stack pointer for traps
  196.  
  197.    struct List rt_Header1;             /* Environment list              */
  198.    struct List rt_Header2;             /* Memory freelist               */
  199.    struct List rt_Header3;             /* Memory allocation list        */
  200.    struct List rt_Header4;             /* Files list                    */
  201.    struct List rt_Header5;             /* Message Ports List            */
  202.    };
  203.  
  204. /* Definitions for RexxTask flag bits                                   */
  205. #define RTFB_TRACE   0                 /* external trace flag           */
  206. #define RTFB_HALT    1                 /* external halt flag            */
  207. #define RTFB_SUSP    2                 /* suspend task?                 */
  208. #define RTFB_TCUSE   3                 /* trace console in use?         */
  209. #define RTFB_WAIT    6                 /* waiting for reply?            */
  210. #define RTFB_CLOSE   7                 /* task completed?               */
  211.  
  212. /* Definitions for memory allocation constants                          */
  213. #define MEMQUANT  16                   /* quantum of memory space       */
  214. #define MEMMASK   0xFFFFFFF0           /* mask for rounding the size    */
  215.  
  216. #define MEMQUICK  (1 << 0 )            /* EXEC flags: MEMF_PUBLIC       */
  217. #define MEMCLEAR  (1 << 16)            /* EXEC flags: MEMF_CLEAR        */
  218.  
  219. /* The SrcNode is a temporary structure used to hold values destined for a
  220.  * segment array.  It is also used to maintain the memory freelist.
  221.  */
  222.  
  223. struct SrcNode {
  224.    struct SrcNode *sn_Succ;            /* next node                     */
  225.    struct SrcNode *sn_Pred;
  226.    APTR     sn_Ptr;                    /* pointer value                 */
  227.    LONG     sn_Size;                   /* size of object                */
  228.    };                                  /* size: 16 bytes                */
  229.  
  230. #endif
  231.